import * as actionTypes from './actionTypes'
import { fromJS } from 'immutable'
const defaultState = fromJS({
    articleList: [],
    recommendList: [],
    topicList: [],
    page: 1
})

const getMoreData = (state, action) => {
    return (
        state.merge({
            articleList: fromJS(action.articleList),
            recommendList: fromJS(action.recommendList),
            topicList: fromJS(action.topicList),
        })
    )
}

export default (state = defaultState, action) => {
    switch (action.type) {
        case actionTypes.GET_HOME_DATA:
            return state.merge({
                articleList: fromJS(action.articleList),
                recommendList: fromJS(action.recommendList),
                topicList: fromJS(action.topicList),
            });
        case actionTypes.GET_MORE_DATA:
            return state.set('articleList', state.get('articleList').concat(action.list)).set('page',action.page)
        default:
            return state
    }
    
}


